<!-- 核心概览 -- 模块和注入器 -->
<!doctype html>
<html ng-app="myApp">
    <head>
        <script src="http://apps.bdimg.com/libs/angular.js/1.4.0-beta.4/angular.min.js"></script>
    </head>
    <body>
        <div ng-controller="ClockCtrl">
            Current time is: {{ time.now}}
        </div>
        <script>
            angular.module('myApp', [])
                    // 实例工厂
                    .factory('time', function ($timeout) {
                        var time = {};
                        (function tick() {
                            time.now = new Date().toString();
                            $timeout(tick, 1000);
                        })();
                        return time;
                    })

                    // 注入控制器
                    .controller('ClockCtrl', function ($scope, time) {
                        $scope.time = time;
                    })
        </script>
    </body>
</html>



